/*
*   @Author: 1296
*   @Date: 2025-03-20
*   @Description: 确认弹窗
*/

<template>
  <div v-if="show" class="confirm-modal">
    <div class="modal-mask" @click.self="handleCancel"></div>
    <div class="modal-wrapper">
      <div class="modal-content">
        <p class="modal-text">{{ messageToShow }}</p>
        <div class="button-group">
          <button class="confirm-btn" @click="handleConfirm">{{ confirmTextToShow }}</button>
          <button class="cancel-btn" @click="handleCancel">{{ cancelTextToShow }}</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false
    },
    message: {
      type: String
    },
    confirmText: {
      type: String
    },
    cancelText: {
      type: String
    }
  },
  computed: {
    messageToShow() {
      return this.message || this.$t('ConfirmChoice');
    },
    confirmTextToShow() {
      return this.confirmText || this.$t('Confirm');
    },
    cancelTextToShow() {
      return this.cancelText || this.$t('Cancel');
    }
  },
  methods: {
    handleConfirm() {
      this.$emit("confirm");
      this.$emit("update:show", false);
    },
    handleCancel() {
      this.$emit("cancel");
      this.$emit("update:show", false);
    }
  }
}
</script>

<style scoped>
.confirm-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
}

.modal-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 30px 40px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  text-align: center;
  z-index: 1;
}

.modal-text {
  font-size: 16px;
  color: #333;
  margin-bottom: 24px;
}

.button-group {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.confirm-btn,
.cancel-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  min-width: 80px;
}

.confirm-btn {
  background: #00c853;
  color: white;
}

.confirm-btn:hover {
  background: #009624;
}

.cancel-btn {
  background: #ff0000;
  color: #ffffff;
}

.cancel-btn:hover {
  background: #970000;
}
</style>
